package com.wy2cloud.sample.resourceserver.controller;

import java.security.Principal;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@Controller
public class HomeController {

	@PreAuthorize("hasAuthority('10')")
	@GetMapping({"/",""})
	public String index() {
		
		return "index";
	}
	
	@ResponseBody
	@PreAuthorize("hasAuthority('20')")
	@GetMapping({"/test",""})
	public String test() {
		
		return "index";
	}
	
	@ResponseBody
	@GetMapping({"/user"})
	public Principal user(Principal principal) {
//        Map<String, String> map = new LinkedHashMap<>();
//        map.put("name", principal.getName());
        return principal;
    }
}
